package com.sky.service.impl;

import com.sky.entity.SetmealDish;
import com.sky.mapper.SetmealDishMapper;
import com.sky.service.SetmealDishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ttao
 * @since 2023/4/24 18:00
 */

@Service
public class SetmealDishServiceImpl implements SetmealDishService {

    @Autowired
    private SetmealDishMapper setmealDishMapper;

    /**
     * 根据 菜品id集合 查询关联的套餐ids集合
     *
     * @param dishIds
     * @return
     */
    @Override
    public List<Long> selectsetmealIdsByDishIds(List<Long> dishIds) {
        return setmealDishMapper.selectsetmealIdsByDishIds(dishIds);
    }

    /**
     * 添加 菜品和套餐表 的关联关系
     *
     * @param setmealDishList
     * @return
     */
    @Override
    public int insertBatch(List<SetmealDish> setmealDishList) {
        return setmealDishMapper.insertBatch(setmealDishList);
    }

    /**
     * 根据套餐id 查询对应的菜品数据
     *
     * @param setmealIds
     * @return
     */
    @Override
    public List<Long> selectBySetmealIds(List<Long> setmealIds) {
        return setmealDishMapper.selectBySetmealIds(setmealIds);
    }

    /**
     * 根据id查询套餐和菜品的关联关系
     *
     * @param id
     */
    @Override
    public List<SetmealDish> selectById(Long id) {
        return setmealDishMapper.selectById(id);
    }

    /**
     * 根据菜品id查询套餐和菜品的关联关系
     *
     * @param dishId
     * @return
     */
    @Override
    public List<SetmealDish> selectByDishId(Long dishId) {
        return setmealDishMapper.selectByDishId(dishId);
    }

    /**
     * 根据套餐id删除 套餐对应的菜品关联关系
     *
     * @param setmealId
     */
    @Override
    public void deleteBySetmealId(Long setmealId) {
        setmealDishMapper.deleteBySetmealId(setmealId);
    }

    /**
     * 根据菜品id 更新套餐菜品表中的关联关系字段(name,price)
     *
     * @param setmealDish
     */
    @Override
    public void updateByDishId(SetmealDish setmealDish) {
        setmealDishMapper.updateByDishId(setmealDish);
    }
}
